package Thread;

public class Demo6 {
    public static void main(String[] args) {
        Thread t = new Thread(()->{
            while (true){
                System.out.println("hallo t");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        //这样的设置得在start前进行
        t.setDaemon(true);
        t.start();
        for (int i=0;i<3;i++){
            System.out.println("主线程 hallo main");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        System.out.println("main 结束");
    }
}
